package com.yyy.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yyy.model.Proxy;
import com.yyy.service.inf.PlanService;
import com.yyy.service.inf.ProxyService;

@Controller
@RequestMapping("index")
public class MainController {
	private Logger logger = Logger.getLogger(MainController.class);	
	@Autowired
	private PlanService planService;
	
	@Autowired
	private ProxyService proxyService;
	
	@RequestMapping("")
	public String index(HttpServletRequest req){
		logger.info("asdasdasdasdasdasd");
//		planService.test();
		List<Proxy> proxys = (List<Proxy>) proxyService.find(null);
		req.setAttribute("proxys", proxys);
		return "index";
	}
	
	@ResponseBody
	@RequestMapping("addProxy")
	public String addProxy(@RequestBody Proxy proxy){
		proxyService.add(proxy);
		return "{\"result\":true}";
	}
}
